package com.sofa.common.config;

import com.sofa.common.Interceptors.JwtProperties;
import com.sofa.common.Interceptors.JwtTokenUserInterceptor;
import com.sofa.common.Interceptors.UserInfoInterceptor;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("com.sofa.common.handler") //加上这个,让全局异常处理器生效,不然Springboot无法扫描到
public class CommonConfig {

    @Bean
    public JwtProperties jwtProperties() {
        return new JwtProperties();
    }

    // 配置 拦截器
    @Bean
    public JwtTokenUserInterceptor jwtTokenUserInterceptor(JwtProperties jwtProperties) {
        return new JwtTokenUserInterceptor(jwtProperties);
    }

    // 配置 拦截器
    @Bean
    public UserInfoInterceptor userInfoInterceptor() {
        return new UserInfoInterceptor();
    }

}
